package com.aat.restful.resteasy.app;

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.support.jaxrs.FastJsonProvider;

public class StartItf {
	private static NettyJaxrsServer nettyServer;
	private static Logger log=LoggerFactory.getLogger(StartItf.class);

	public static void main(String[] args) {
		String host = "0.0.0.0";
		String rootResourcePath = "";
		int port = Integer.parseInt("56789");
		int executorThreadCount=16;

		// resteasy
		ResteasyDeployment deployment = new ResteasyDeployment();
		
		ApplicationScan appscan = new ApplicationScan().setScanPackage("com.sense.cloud.sms.itf");
		deployment.setApplication(appscan);
		
		ResteasyProviderFactory factory=new ResteasyProviderFactory();
		factory.registerProvider(FastJsonProvider.class,true);
		
		deployment.setProviderFactory(factory);
		
		//nettyServer
		nettyServer = new NettyJaxrsServer();
		nettyServer.setDeployment(deployment);
		nettyServer.setHostname(host);
		nettyServer.setPort(port);
		nettyServer.setRootResourcePath(rootResourcePath);
		nettyServer.setSecurityDomain(null);
		nettyServer.setExecutorThreadCount(executorThreadCount);
		nettyServer.start();
		log.info("server start port "+port);
	}

}
